<template>
  <view class="content">
    <uni-nav-bar title="核销记录" background-color="#f7f7f7" fixed :border="false" height="88rpx" left-icon="left"
      @clickLeft="onClickLeft" statusBar></uni-nav-bar>
    <!-- <view class="safe-area" :style="{ height: statusBarHeight + 'px' }" style="width: 100%;"></view> -->
    <!-- <view class="main" style="flex:1;"> -->
    <scroll-view class="scroll-view_H" scroll-y @refresherrefresh="refresherrefreshFn" refresher-enabled="true"
      :show-scrollbar="false" @scrolltolower="lower" :refresher-triggered="triggered" enhanced
      :style="{ height: `calc(100vh - 88rpx - ${statusBarHeight}px)` }">
      <view class="bigBox" v-for="item in recordList" :key="item.id">
        <view class="infoCard">
          <!-- <image :src="item.headImg" mode="aspectFit" class="goodsImg"></image> -->
          <image :src="item.imgUrl ? item.imgUrl : '/static/index/noneImg.png'" mode="aspectFill" class="goodsImg">
          </image>
          <view class="info">
            <view class="name">会员手机号：{{ item.memberPhone }}</view>
            <view class="tokenNum">
              <view class="count u-ellipsis" style="margin-right: 10rpx;width: 45%;">{{ item.commodityName }}</view>
              <view class="count">消耗数字资产：{{ item.consumeNum }}</view>
            </view>
            <view class="count">产地：{{ item.producerArea }}</view>
          </view>
        </view>
        <view class="one">兑换流水号：{{ item.serialNum }}</view>
        <view class="one">兑换时间：{{ item.consumerTime | parseTime('YYYY-MM-DD HH:mm:ss') }}</view>
      </view>
      <uni-load-more :status="loading" v-if="recordList.length > 0"></uni-load-more>
      <view
        style="width: 100%;height: 100%;background-color: #f7f7f7;display: flex;justify-content: center;align-items: center;"
        v-if="recordList.length == 0">
        <image src="/static/index/nonedata.png" mode="aspectFill" style="width: 400rpx;height: 400rpx;"></image>
      </view>
    </scroll-view>
    <!-- </view> -->
  </view>
</template>

<script>
import { reqVerificationRecord } from '@/apis/member.js'
export default {
  name: "chargeOff",
  data() {
    return {
      recordList: [],
      page: {
        pageNum: 1,
        pageSize: 15
      },
      triggered: false, // 是否触发下拉刷新
      loading: 'loading', // 是否触发上拉加载
    }
  },
  onLoad() {
    this.getrecordList()
  },
  onShow() {
  },
  methods: {
    refresherrefreshFn() {
      this.page.pageNum = 1
      this.triggered = true
      this.recordList = []
      this.loading = "loading";
      this.getrecordList();
    },
    async getrecordList() {
      const res = await reqVerificationRecord({ ...this.page })
      if (res.code === 200) {
        this.recordList = [...this.recordList, ...res.data.list]
        this.nextPage = res.data.nextPage
        console.log('recordList:', res);
        this.triggered = false
        if (res.data.isLastPage) {
          this.loading = "noMore"
        }
      }
    },
    lower() {
      if (this.loading == "noMore") {
        return;
      }
      this.page.pageNum++;
      this.loading = "loading";
      this.getrecordList();
    },
  }
}
</script>

<style>
page {
  background: #d3e3fd;

}
</style>
<style lang="scss" scoped >
.content {
  height: 100%;
  background-color: #d3e3fd;
  display: flex;
  flex-direction: column;
}

view {
  box-sizing: border-box;
}

.bigBox {
  background-color: #fff;
  border-radius: 20rpx;
  height: 300rpx;
  margin: 20rpx;
  padding: 20rpx 20rpx;
  font-size: 26rpx;
  line-height: 50rpx;
}

.infoCard {
  display: flex;
  font-size: 26rpx;
  // margin: 20rpx;

  align-items: center;
  height: 160rpx;
  line-height: 50rpx;
  // border-radius: 20rpx;
  background-color: #fff;
  // border: 1px solid #619cfc;

  .goodsImg {
    margin-right: 20rpx;
    width: 150rpx;
    height: 150rpx;
    border-radius: 10rpx;
    background-color: #eee;
  }

  .info {
    flex: 1;
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 10rpx 0;
  }

  .tokenNum {
    display: flex;
    width: 100%;
    // justify-content: space-between;
  }
}
</style>
